package learningThread.syn.part1;

public class OperationObj {

    private int num = 0;

    /**
     * 由于线程不同步,所以导致 num值会被修改
     * @param username
     */
    public void addI(String username){
        try {
            if ("a".equals(username)) {
                num = 100;
                System.out.println("a set over");
                Thread.sleep(2000);
            }else{
                num = 200;
                System.out.println("b set over");
            }
            System.out.println(username+" num= "+num);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
